package belf.migrate.engine.ddl.helper.mysql;

import belf.migrate.plugin.mysql.antlr.MySqlParserBaseListener;
import org.antlr.v4.runtime.tree.TerminalNode;

/**
 * MySql的语句的通用的监听器，用于遍历终端节点，重构新的SQL
 */
public class MySqlCommonListener extends MySqlParserBaseListener {
    protected MySqlAntlrBuilder builder;

    public MySqlCommonListener(MySqlAntlrBuilder builder) {
        this.builder = builder;
    }

    @Override
    public void visitTerminal(TerminalNode node) {
        builder.output(node);
    }

    public String toSql() {
        return builder.toSql();
    }
}
